<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<script type="text/javascript">
    var rowId = 0;

    $('.ui-reset , #refresh_collateralGrid').click(function(){
        $("#collateralGrid").jqGrid('setGridParam',{search:false});
        var postData = $("#collateralGrid").jqGrid('getGridParam','postData');
        $.extend(postData,{searchField:"",searchString:"",searchOper:""});
        $.extend(postData,{filters:""});
        $("#collateralGrid").trigger("reloadGrid");
    });

    $.subscribe('searchCollateralGrid', function(event,data) {
        $("#collateralGrid").jqGrid('searchGrid', {drag:true,closeAfterSearch:true,closeOnEscape:true,sopt:['eq'],caption:"Search collateral"} );
    });
    
    $.subscribe('collateralGridComplete',function(event,data){
        $( "#collateralGrid_search" ).button( "option", "disabled", false );
        $( "#collateralGrid_showhide" ).button( "option", "disabled", false );
    });
    
    $.subscribe('showhideCollateralGrid', function(event,data) {
        $("#collateralGrid").jqGrid('setColumns',{});
    });

</script>
<div class="gridOptsContainer">
    <sj:submit button="true" cssStyle="font-size:14px;" disabled="true" id="collateralGrid_search" onClickTopics="searchCollateralGrid" value="Search Collateral"/>
    <sj:submit button="true" cssStyle="font-size:14px;" disabled="true" id="collateralGrid_showhide" onClickTopics="showhideCollateralGrid" value="Show/Hide Columns"/>

</div>
<s:url id="remoteurl" action="grid-collaterals"/>

<sjg:grid
    id="collateralGrid"
    caption="Cashmate Collateral"
    dataType="json"
    href="%{remoteurl}"
    gridModel="gridModel"
    pagerButtons="true"
    pagerInput="true"
    rowList="10,20,50"
    rowNum="50"
    loadingText="Requesting Data..."
    width="970"
    shrinkToFit="true"
    pager="true"
    hoverrows="true"
    rownumbers="true"
    autoencode="true"
    viewrecords="true"
    navigator="true"
    navigatorAdd="false"
    navigatorDelete="false"
    navigatorEdit="false"
    navigatorSearch="true"
    navigatorView="true"
    onGridCompleteTopics="collateralGridComplete"
    >


    <sjg:gridColumn name="collateralid"
                    index="collateralid"
                    title="Collateral id. (Not Editable)"
                    sortable="false"
                    key="true"
                    hidden="false"/>

    <sjg:gridColumn name="makeandtype"
                    index="makeandtype"
                    title="Make and Type"
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="brand"
                    index="brand"
                    title="Brand"
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="serialno"
                    index="serialno"
                    title="Serial No."
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="modelno"
                    index="modelno"
                    title="Model No."
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="regcertno"
                    index="regcertno"
                    title="Reg. Cert. No."
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="motorno"
                    index="motorno"
                    title="Motor No."
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="chasisno"
                    index="chasisno"
                    title="Chassis No"
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="plateno"
                    index="plateno"
                    title="Plate No."
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="fairmarketvalue"
                    index="fairmarketvalue"
                    title="Fair Market Value"
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="location"
                    index="location"
                    title="Location"
                    sortable="true"
                    align="center"
                    />
    <sjg:gridColumn name="generalcondition"
                    index="generalcondition"
                    title="General Condition"
                    sortable="true"
                    align="center"
                    />
    

</sjg:grid>
